<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>客服登陆</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script type="text/javascript" src="../../js/cookie.js"></script>

</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message"><img src="../../images/timg1.png"></div>
    <div id="darkbannerwrap">客服登录</div>
    <form method="post" class="layui-form" action="localhost:8080/login.do?func=login" method="post">
        <input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
        <img src="../../images/user.png" class="login-images-user">
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
        <img src="../../images/pwd.png" class="login-images-pwd">
        <hr class="hr15">
        <button class="layui-btn" lay-submit lay-filter="formDemo" style="width:100px;height: 40px;line-height: 20px ">
            登陆
        </button>
        <hr class="hr20">
    </form>
</div>
<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            // layer.msg(JSON.stringify(data.field));
            $.ajax({
                url: "/login.do?func=login",
                type: "post",
                data: data.field,
                contentTypeString: "application/json",
                success: function (res) {
                    console.log("ajax成功");
                    if (res.code == 1) {
                        //录入人员
                        layer.msg("录入人员,登陆成功");
                        window.location.href = "/html/damin/entry.html";

                    } else if (res.code == -1) {
                        //超级管理员
                        layer.msg("超级管理员,登陆成功");
                        window.location.href = "/html/damin/superman.html";

                    } else if (res.code == 0) {
                        //客服页面
                        layer.msg("客服,登陆成功");
                        window.location.href = "/html/damin/customer.html";

                    } else if (res.code == 400) {
                        alert(res.msg);
                    }else if(res.code == 2){
                        layer.msg("你是配送人员,不能登录此系统!");

                    }
                },
                error: function (e) {
                    console.log("error:", e);
                }
            });
            // return false;
        });
    });
</script>
<!--<script>-->
<!--$(function  () {-->
<!--layui.use('form', function () {-->
<!--$("input#login").on("click", function () {-->
<!--console.log($("[name=username]").val());-->
<!--console.log($("[name=password]").val());-->
<!--var uname = $("input[name=username]").val();-->
<!--var pwd = $("input[name=password]").val();-->
<!--var data={"uname":uname,"pwd":pwd};-->
<!--$.ajax({-->
<!--url: "/login",-->
<!--data: {"username": $("[name=username]").val(), "password": $("[name=password]").val()},-->
<!--type: "post",-->
<!--dataType: "json",-->

<!--success: function (data) {-->
<!--if (uname==123456&&pwd==123456) {-->
<!--layer.msg("欢迎你,尊敬的管理员",function(){-->
<!--location.href = 'superman.html'-->
<!--});-->
<!--}else  if (uname==666666&&pwd==999999) {-->
<!--layer.msg("欢迎你,尊敬的客服",function(){-->
<!--location.href = 'customer.html'-->
<!--});-->
<!--}else {-->
<!--layer.msg("欢迎你,尊敬的录入人员",function(){-->
<!--location.href = 'entry.html';-->
<!--});-->
<!--}-->
<!--},-->
<!--error:function (e) {console.log(e)}-->
<!--});-->
<!--return false;-->
<!--})-->
<!--})-->
<!--})-->
<!--</script>-->
</body>
</html>